package com.zzx.project.controller;

import com.zzx.project.entity.Practical;
import com.zzx.project.service.PracticalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

//实用网站Controller
@Controller
@RequestMapping("practical")
public class PracticalController {

    @Autowired
    PracticalService practicalService;

    //添加实用网站
    @RequestMapping("add")
    public String addWeb(Practical practical, Model model) {
        int flag = practicalService.addWeb(practical);
        if (flag > 0) {
            model.addAttribute("tip", "添加成功，请等待审核");
        } else {
            model.addAttribute("tip", "添加失败，请联系站长");
        }
        //更新操作
        model.addAttribute("webs", practicalService.getAll());
        return "main/practicalWeb";
    }
}
